<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>增加</title>
<link href="/resource/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap.js"></script>

<script type="text/javascript">
function getCarInfo(){
	var cno =$("#cno").val();//获取输入的车牌号
	$.get("/getCarInfo",{cno:cno},function(car){//根据车牌号查询车辆是否存在，如果存在则自动回显
	  if(car!=null){
	     //让车类型选中
		  $("#carType").val(car.carType);
		  //让车牌颜色选中
		  $("#color").val(car.color);
        //为车长度赋值
        $("[name='length']").val(car.length)
        //车的id
        $("[name='id']").val(car.id);
	  }	
		
	})
	
}


</script>

</head>
<body>
 <h3>车辆入库</h3>
 <hr>
   <form action="add" method="post">
   <input type="hidden" name="id" >
   
   车牌号码：<input type="text" name="cno" onblur="getCarInfo()" id="cno"><br/>
   车牌类型：
     <select name="carType" id="carType">
     
      <c:forEach items="${types}" var="type">
       <option value="${type}" >${type.name}</option>
      </c:forEach>
     
     </select>
   
      
   <br/>
   车牌颜色：
    <select name="color" id="color">
     <option value="黑">黑</option>
     <option value="白">白</option>
     <option value="红">红</option>
     <option value="蓝">蓝</option>
     <option value="黄">黄</option>
    </select>
   
   <br/>
   车牌长度：<input type="text" name="length" ><br/>
   入库时间：<input type="text" name="inTime" id="inTime" value='<fmt:formatDate value="${inTime}" pattern="yyyy-MM-dd HH:mm"/>'><br/>
   
    <button type="submit">入库</button>
   
   
   
   </form>
</body>
</html>